"""

    异步操作Postgresql

"""

import asyncpg
import asyncio
from async_db.schema import *


async def main():
    connection = await asyncpg.connect(
        host="127.0.0.1",
        port="5432",
        database="products",
        user="around",
        password="zhouwei",
    )
    statements = [
        CREATE_BRAND_TABLE,
        CREATE_PRODUCT_TABLE,
        CREATE_PRODUCT_COLOR_TABLE,
        CREATE_PRODUCT_SIZE_TABLE,
        CREATE_SKU_TABLE,
        SIZE_INSERT,
        COLOR_INSERT,
        # BRAND_INSERT
    ]
    print("开始创建表...")
    for statement in statements:
        status = await connection.execute(statement)
        print(status)
    print("表创建完成")
    await connection.close()


asyncio.run(main())
